#include "DeclAST.h"
#include "Globe.h"
#include <iostream>
void DeclAST::Dump() const 
{
    std::cout << "{" << "\"type\":\"Decl\","<<"\"const\":\""<<std::boolalpha<<this->constDecl<<"\"";
    for (const auto& i : this->decl)
    {
        std::cout << ",\"" << i.first << "\":";
        if (i.second == nullptr)
            std::cout << "\"\"";
        else
            i.second->Dump();
    }
    std::cout << "}";
}

void DeclAST::Analyze() const
{
    for (const auto& i : this->decl)
    {
        if (i.second == nullptr)continue;
        i.second->Analyze();
        cmd_val val = cmd_val(cmd_val::MEMORY, CurrentValMgr->QueryOffsetRegister(i.first), CurrentValMgr->QueryOffset(i.first));
        GENASM(cmd_code::MOV, CVR(EAX), val);
    }
}
